package com.tdkj.action.backstage.exchangerate;

import javax.annotation.Resource;

import com.tdkj.action.BaseAction;
import com.tdkj.model.exchangerate.BeanExchangeRate;
import com.tdkj.service.exchangerate.IBeanExchangeRateService;

public class ExchangeRateAction extends BaseAction {

	private static final long serialVersionUID = 5924641671173187558L;

	private IBeanExchangeRateService exchangeRateService;
	private BeanExchangeRate exchangeRate;
	private long value;

	public long getValue() {
		return value;
	}

	public void setValue(long value) {
		this.value = value;
	}

	private long id;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public BeanExchangeRate getExchangeRate() {
		return exchangeRate;
	}

	public void setExchangeRate(BeanExchangeRate exchangeRate) {
		this.exchangeRate = exchangeRate;
	}

	@Override
	public String execute() throws Exception {
		return "success";
	}

	// 获取积分到硬币
	public String getIntegral() {
		exchangeRate = exchangeRateService.getExchangeRate();
		return "integral";
	}

	// 获取 人民币到金币
	public String getGold() {
		exchangeRate = exchangeRateService.getExchangeRate();
		return "gold";
	}

	// 获取银币打折
	public String getDiscount() {
		exchangeRate = exchangeRateService.getExchangeRate();
		return "discount";
	}

	// 保存打折
	public String updateDiscount() {
		//exchangeRate = this.getBaseService().findEntity(BeanExchangeRate.class);		
		this.getBaseService().saveOrUpdate(exchangeRate, BeanExchangeRate.class);
		return getDiscount();
	}

	// 保存金币
	public String updateGold() {
		//exchangeRate = this.getBaseService().findEntity(BeanExchangeRate.class);		
		this.getBaseService().saveOrUpdate(exchangeRate, BeanExchangeRate.class);
		return getGold();
	}

	// 保存积分
	public String updateIntegral() {
		//exchangeRate = this.getBaseService().findEntity(BeanExchangeRate.class);
		this.getBaseService().saveOrUpdate(exchangeRate, BeanExchangeRate.class);
		return getIntegral();
	}

	@Resource
	public void setExchangeRateService(IBeanExchangeRateService exchangeRateService) {
		this.exchangeRateService = exchangeRateService;
	}

	
	
}
